Adding some more judges, here and there.
[and.git] / UVa / 993 - Product of digits / 993.cpp
blob5bab61733fa9a570f78086affff0c1fb009b1acf
1 /*
2 Problem: 993 - Product of digits
3 Author: Andrés Mejía-Posada
4 (http://blogaritmo.factorcomun.org)
6 */
8 using namespace std;
9 #include <algorithm>
10 #include <iostream>
11 #include <iterator>
12 #include <sstream>
13 #include <fstream>
14 #include <cassert>
15 #include <climits>
16 #include <cstdlib>
17 #include <cstring>
18 #include <string>
19 #include <cstdio>
20 #include <vector>
21 #include <cmath>
22 #include <queue>
23 #include <deque>
24 #include <stack>
25 #include <map>
26 #include <set>
28 #define D(x) cout << #x " is " << x << endl
30 int main(){
31 int c;
32 for (cin >> c; c--; ){
33 int n;
34 cin >> n;
36 if (n == 1){
37 cout << 1 << endl;
38 continue;
41 string ans = "";
42 for (int i=9; i>=2; --i){
43 while (n % i == 0){
44 n /= i;
45 ans = char(i+'0') + ans;
49 if (n > 1){
50 ans = "-1";
53 cout << ans << endl;
55 return 0;